<template>
  <van-row class="panel-rectify-operate">
    <van-cell-group title="整改措施审核">
      <van-row class='radio-area' gutter="10">
        <van-radio-group v-model="result" direction="horizontal">
          <van-col span="10" offset="2">
            <van-radio name="1">审核拒绝</van-radio>
          </van-col>
          <van-col span="10" offset="2">
            <van-radio name="0">审核通过</van-radio>
          </van-col>
        </van-radio-group>
      </van-row>
      <van-row class="split-h last-row"/>
      <van-field v-if="result === '1'" class='input-area' label-width="70px"  required v-model="reason" rows="1" autosize label="拒绝原因" type="textarea" maxlength="100" placeholder="请输入审核拒绝原因" show-word-limit/>
      <card-receivers v-if="result === '0'" :parentPath="parentDept" :showChildren="1" v-model="receivers"/>
      <van-row class='operate-area'>
        <van-button type="info" :disabled="result === ''" @click="submit">提交审核结果</van-button>
      </van-row>
    </van-cell-group>
  </van-row>
</template>

<script>
import ApiMixin from '@/mixins/ApiMixin'
import CardReceivers from '@/views/common/card/CardReceivers'
export default {
  name: 'PanelRectifyAppr',
  mixins: [ApiMixin],
  components: { CardReceivers },
  data () {
    return {
      result: '',
      reason: '',
      parentDept: this.rectify.dutyDept,
      formData: this.$vo.createRectifyFormData(),
      receivers: []
    }
  },
  mounted() {
    if (this.rectify.flow_type == 1 && this.rectify.rectify_status == 'rectify') {
        this.parentDept = this.rectify.reviewDept
    }
  },
  methods: {
    submit () {
      if (this.result === '1' && this.reason.trim() === '') {
        this.$dialog.alert({
          message: '请输入审核拒绝原因'
        })
        return
      }
      if (this.result === '0' && this.receivers.length === 0) {
        this.$dialog.alert({
          message: '请选择接收人员'
        })
        return
      }
      this.formData.op = this.$vo.RectStatus.APPR
      this.formData.receivers = this.receivers
      this.formData.approve_result = this.result
      this.formData.approve_content = this.reason
      // 提交
      this.doUpdateRectify()
    }
  }
}
</script>

<style scoped>

</style>
